#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include<sstream>
using namespace std;

int main() {
    string r, s, z, v;
    getline(cin, r);
    cin >> s;
    stringstream ssin(r);
    while (ssin >> z)
    {
        for (int j = 0; j < z.size(); j++)
        {
            int i = 0;
            for (int len = s.size(); i < len; i++)
            {
                if (z[j] == s[i])
                    break;
            }
            if (i == s.size())
                v += z[j];
        }
        v += ' ';
    }
    cout << v << endl;
    return 0;
}